﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class news_delete : BasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            int id = int.Parse(Request["id"]);
            string newsTypeId = Server.UrlDecode(Request["newsTypeId"]);
            CMSModel.CMSEntities dal = DAL.DBManager.GetCmsEmtity();
            CMSModel.News news = dal.News.First(x => x.id == id);
            try
            {
                dal.DeleteObject(news);
                dal.SaveChanges();
                ClientScript.RegisterStartupScript(GetType(), "delete", "alert('删除成功!'),document.location='Default.aspx?newsTypeId="+newsTypeId+"'", true);
            }
            catch (Exception ex)
            {
               
                LogYuMin.LogWriter.GetWriter(LogYuMin.LogFile.error).Write(GetType(), "DeleteNews", LogYuMin.LogStates.ERROR, ex);
                ClientScript.RegisterStartupScript(GetType(), "delete", "alert('删除失败!')", true);
            }
        }
    }
}